import upload from '@/utils/upload'
import request from '@/utils/request'
import store from '@/store/index.js'
import auth from '@/plugins/auth.js'

// 查询设备信息
export function QueryDeviceInstallList(UrlParams, body) {
	if (!auth.hasRole("admin")) { //没有admin权限的情况下添加请求条件
		body.queryParam.district = store.state.user.user.remark
	}
	console.log('query', {
		url: '/elder/deviceinstall/page',
		method: 'post',
		params: UrlParams,
		data: body
	});
	return request({
		url: '/elder/deviceinstall/page',
		method: 'post',
		params: UrlParams,
		data: body
	})
}

// 查询指定设备详细信息
export function getDeviceInstall(Id) {
	return request({
		url: '/elder/deviceinstall/' + Id,
		method: 'get'
	})
}

// 新增设备信息
export function addDeviceInstall(data) {
	// console.log('addDeviceInstall',{
	//   url: '/elder/deviceinstall/save',
	//   method: 'post',
	//   data: data
	// });
	return request({
		url: '/elder/deviceinstall/save',
		method: 'post',
		data: data
	})
}

// 修改设备信息
export function updateDeviceInstall(data) {
	return request({
		url: '/elder/deviceinstall/update',
		method: 'post',
		data: data
	})
}

// 删除设备信息
export function delDeviceInstall(Ids) {
	return request({
		url: '/elder/deviceinstall/delete',
		method: 'delete',
		data: Ids
	})
}

// 查询设备历史数据
export function QueryDeviceInstallHistory(id) {
	console.log('QueryDeviceInstallHistory', {
		url: '/elder/deviceinstall/history/' + id,
		method: 'post',
		// params: UrlParams,
		// data:body
	});
	return request({
		url: '/elder/deviceinstall/history/' + id,
		method: 'post',
		// params: UrlParams,
		// data:body
	})
}

// 通过设备SN扫码获取设备信息id 
export function QueryDeviceInstallDev(id) {
	return request({
		url: '/elder/deviceinstall/dev/' + id,
		method: 'post',
		// params: UrlParams,
		// data:body
	})
}